<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .box {
            width: 600px;
            height: auto;
            margin: 10px auto;
            border: 1px solid ghostwhite
        }

        .tou {
            width: 600px;
            height: 40px;
            background-color: #FFC0CA;
        }

        input {
            width: 200px;
            height: 20px;
            margin-top: 10px;
            margin-left: 190px;
            outline: none;
        }

        img {
            width: 600px;
        }
    </style>
</head>

<body>
    <div id="root">

    </div>
</body>
<script src="../react.js"></script>
<script src="../react-dom.js"></script>

<!-- 用来将jsx语法转化为js语法 -->
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.3/jquery.js"></script>
<script type="text/babel">
    class App extends React.Component {
        state = {
            list: [
                {
                    name: "白羊座",
                    url: "./image/baiyang.png"
                }, {
                    name: "处女座",
                    url: "./image/chunv.png"
                }, {
                    name: "金牛座",
                    url: "./image/jinniu.png"
                }, {
                    name: "巨蟹座",
                    url: "./image/juxie.png"
                }, {
                    name: "魔羯座",
                    url: "./image/moxie.png"
                }, {
                    name: "射手座",
                    url: "./image/sheshou.png"
                }, {
                    name: "狮子座",
                    url: "./image/shizi.png"
                }, {
                    name: "双鱼座",
                    url: "./image/shuangyu.png"
                }, {
                    name: "双子座",
                    url: "./image/shuangzi.png"
                }, {
                    name: "水平座",
                    url: "./image/shuiping.png"
                }, {
                    name: "天秤座",
                    url: "./image/tiancheng.png"
                }, {
                    name: "天蝎座",
                    url: "./image/tianxie.png"
                },
            ],
            add: ""
        }
        render() {
            let { name, url, list } = this.state
            return (
                <div className="box">
                    <div className="tou">
                        <input type="text" placeholder='请输入星座' onChange={(e) => {
                            this.setState({
                                add: e.target.value
                            })
                        }} />
                    </div>
                    {list.map((item, index) => {
                        return (
                            item.name.includes(this.state.add) &&
                            <div key={index}>
                                <img src={item.url} alt="" />
                            </div>
                        )

                    })

                    }
                </div>
            )
        }
    }
    ReactDOM.render(<App />, document.getElementById("root"))
</script>

</html>